package br.com.guiav6.sisguia.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import br.com.guiav6.sisguia.dao.TipoServicoDao;
import br.com.guiav6.sisguia.entity.TipoServico;
import br.com.guiav6.sisguia.service.TipoServicoService;

@Service("tipoServicoService")
public class TipoServicoServiceImpl implements TipoServicoService {
	
	@Autowired(required = true)
	private TipoServicoDao tipoServicoDao;

	@Override
	public TipoServico findById(Long idTipoServico) {
		return tipoServicoDao.findById(idTipoServico);
	}

	@Override
	public List<TipoServico> findAll() {
		return tipoServicoDao.findAll();
	}

	@Transactional
	@Override
	public void salvar(TipoServico tipoServico) {
		if(tipoServico.getId() != null)
			tipoServicoDao.merge(tipoServico);
		else
			tipoServicoDao.persist(tipoServico);
	}
	
	@Transactional
	@Override
	public void deletar(TipoServico tipoServico) {
		tipoServicoDao.delete(tipoServico);
	}

}